package com.yllt4cloud.shangmi.biz.control;

import com.yllt4cloud.common.core.util.ResultResp;
import com.yllt4cloud.common.ddbase.param.jsonparam.RequestJsonParam;
import com.yllt4cloud.common.ddbase.util.JsonUtil;
import com.yllt4cloud.shangmi.api.dto.RegionDto;
import com.yllt4cloud.shangmi.api.entity.Region;
import com.yllt4cloud.shangmi.biz.service.IRegionService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: yaoxj
 * @create: 2020-01-20 17:16
 **/
@RestController
@RequestMapping("region")
@AllArgsConstructor
public class RegionAct {
    private IRegionService regionService;
    @RequestMapping(value = "list")
    public ResultResp<?> regionList(@RequestJsonParam("data") RegionDto param) {
        RegionDto regionDto=new RegionDto();
        //省级
        if(param.getType().equals(1)){
            regionDto.setType(1);
        }
        if(param.getType().equals(2)){
            if(null==param.getSuperId()){
                return ResultResp.success(new ArrayList<Region>());
            }
            regionDto.setSuperId(param.getSuperId());
            regionDto.setType(2);
        }
        List<Region> resultList =regionService.queryRegionList(regionDto);
        return ResultResp.success(resultList);
    }
}
